package com.yirui.serialcomm.core.protocol;

import com.yirui.serialcomm.core.Connector;
import com.yirui.serialcomm.core.parse.PacketParser;
import io.netty.buffer.ByteBuf;

/**
 * @author Dujie
 * @create 2025/8/6
 * @since 1.0.0
 */
abstract public class AbstractServer implements Server{
    private Connector connector;
    protected PacketParser packetParser;
    @Override
    public void setConnector(Connector connector) {
        this.connector = connector;
    }

    @Override
    public Connector getConnector() {
        return connector;
    }

    @Override
    public void stop() {
        if(connector != null){
            connector.close();
        }
    }

    public abstract void send(ByteBuf buffer);

    public void setPacketParser(PacketParser packetParser){
        this.packetParser = packetParser;
    }
}
